//
//  UIBarButtomItem.swift
//  weibo19
//
//  Created by Arvin on 15/11/19.
//  Copyright © 2015年 Arvin. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience init(image: String, target: AnyObject?, actionName: String?) {
        let btn = UIButton(type: .Custom)
        btn.setImage(UIImage(named: image), forState: .Normal)
        btn.setImage(UIImage(named: (image + "_highlighted")), forState: UIControlState.Highlighted)
        // 注意:
        if let action = actionName, targetObj = target {
            btn.addTarget(targetObj, action: Selector(action), forControlEvents: .TouchUpInside)
        }
        btn.sizeToFit()
        self.init(customView: btn)
    }
    
}
